<template>
    <div class="container">
        <div>
            <head-bar height="80" middleText="新建跟进" :leftClick="returnPage"></head-bar>
        </div>
        <div class="follow-content">
            <div class="content-label">
                <text class="content-label-tag">*</text>
                <text class="content-label-t">跟进内容</text>
            </div>
            <textarea placeholder="请输入跟进内容" :value="form.followContent" class="content"></textarea>
            <div class="content-type-area">
                <div @click="openAll" class="content-type-panel border-right-line">
                    <image class="content-type-camera icon" src="root:img/icon/camera.png"></image>
                </div>
                <div class="content-type-panel">
                    <image class="content-type-photo icon" src="root:img/icon/photo.png"></image>
                </div>
            </div>
        </div>
        <cell-input type="text" :hasTopBorder="true" label="*" @getVal="getOrgNameVal" title="客户名称"></cell-input>
        <cell-date label="*" title="跟进日期" @getVal="getFollowTimeVal"></cell-date>
        <cell-select label="*" :selectData="followTypeData" @getVal="getFollowTypeVal" title="跟进类型"></cell-select>
        <cell-select label="*" :selectData="followMethodData" @getVal="getFollowMethodVal" title="跟进方式"></cell-select>
        <cell-select label="*" :selectData="linkManData" @getVal="getLinkManVal" title="联系人"></cell-select>


        <wxc-cell :has-top-border="false" title="为下次跟进新建代办任务">
            <switch :checked="nextFollowTypeChecked" slot="value" @change="nextFollowTypeChecked = !nextFollowTypeChecked"></switch>
        </wxc-cell>

    </div>
</template>


<style scoped>
    .time-div {
        height: 100px;
        width: 750px;
    }
</style>

<style>
    .container {
        flex-direction: column;
        background-color: #F6F6F6;
    }

    .icon {
        width: 50px;
        height: 50px;
    }

    .content-type-photo {

    }

    .content-type-camera {

    }

    .content-type-panel {
        width: 360px;
        height: 75px;
        background-color: white;
        justify-content: center;
        align-items: center;
    }

    .border-right-line {
        border-right-color: #e2e2e2;
        border-right-width: 1px;
    }

    .content-type-area {
        flex-direction: row;
        width: 750px;
        height: 75px;
        border-top-color: #e2e2e2;
        border-top-width: 1px;
        padding-left: 20px;
    }

    .content {
        width: 750px;
        height: 200px;
        padding-left: 20px;
    }

    .follow-content {
        background-color: white;
        padding-top: 36px;
    }

    .content-label {
        flex-direction: row;
        padding-left: 15px;
        width: 750px;
    }

    .content-label-tag {
        font-size: 32px;
        color: #ff5d54;
    }

    .content-label-t {
        font-size: 32px;
        color: #272727;
    }
</style>

<script>
    import {WxcCell} from 'weex-ui'

    import headBar from '../components/headBar.vue'
    import cellDate from '../components/cellDate.vue'
    import cellInput from '../components/cellInput.vue'
    import cellSelect from '../components/cellSelect.vue'
    import nw from '../network/nw.js'

    const navigator = weex.requireModule('navigator')
    var param = navigator.param()


    export default {
        components: {headBar, cellInput, cellSelect, cellDate,WxcCell},
        data: {
            nextFollowTypeChecked:false,//是否转任务
            form: {
                followTime: '',
                followContent: '',
                contentType: '1000',//内容的类型1000:文本内容，1100：图片内容，1200:视屏内容
                contentType: '1000',//内容的类型1000:文本内容，1100：图片内容，1200:视屏内容
                nextFollowType:'',
            },
            followTypeData: [
                //1000:客户，1100：普天宝，1200：商品，1300：订单，1400：财务，1500：投诉，1600：其他，1700：确认需求，1800：跟踪维护
                {name: '客户', value: '1000'},
                {name: '普天宝', value: '1100'},
                {name: '商品', value: '1200'},
                {name: '订单', value: '1300'},
                {name: '财务', value: '1400'},
                {name: '投诉', value: '1500'},
                {name: '其他', value: '1600'},
                {name: '确认需求', value: '1700'},
                {name: '跟踪维护', value: '1800'}
            ],
            followMethodData: [
                {name: '电话', value: '1000'},
                {name: 'QQ或微信', value: '1100'},
                {name: '现场拜访', value: '1200'}
            ],
            linkManData: []
        },
        methods: {
            //返回上个页面
            returnPage() {
                nav.back()
            },

            //客户名称
            getOrgNameVal() {
                this.form.followTime = data
            },
            //跟进时间
            getFollowTimeVal(data) {
                this.form.followTime = data
            },

            //跟进类型
            getFollowTypeVal(data) {
                this.form.followType = data
            },
            //跟进方式
            getFollowMethodVal(data) {
                this.form.followMethod = data
            },
            //联系人
            getLinkManVal(data) {
                this.form.contactName = data
            },

            openAll() {


                var self=this;
                const photo = weex.requireModule('photo');
                photo.open(500,800,'#000000','#ffffff','#ffffff',function(e){
                    self.src=e.path;
                    var param={};
                    var header={};
                    var path={};
                    path.file=e.path;
                    var net=weex.requireModule("net");
                    net.postFile('http://xxx/upload',param,header,path,()=>{
                        //start
                    },(e)=>{
                        //succcess
                        var modal=weex.requireModule("modal")
                        modal.toast({message:'上传成功！'})
                    },()=>{
                        //compelete

                    },()=>{
                        //exception
                        var modal=weex.requireModule("modal")
                        modal.toast({message:'上传异常！'})
                    })
                });


            }


        },
        created() {
            var self = this
            nw.postDefine('/app/yxq/follow/queryUserAndContect', {
                data: {userType: param.userType, userId: param.userId},
                success(res) {
                    for (let i in res) {
                        var ele = res[i]
                        if (ele) {
                            self.linkManData.push({name: ele.userName, value: ele.userName})
                        }
                    }
                }
            })
        }
    }
</script>